home *** CD-ROM | disk | FTP | other *** search
- /* Why Settle For LESS ?
-
- This program runs More as a workbench process from the Cli, so that it will
- make a separate window like Less. Yes, Virginia, I like More better than
- Less. Especially this version where I DiskX'd the window specification to
- be borderless on the topmost screen (using ConMan 1.3). There's little
- point in using this from CLImax without that DiskX'd version. It looks for
- More on the resident list. If it isn't found there, it checks
- SYS:Utilities/More, and then C:More. Hopefully, this program is "pure" like
- More itself.
-
- God DAMN, it works! 5/15/89 (Lake Jawi Day.) By Paul Kienitz, public domain.
- */
-
-
- #include <exec/exec.h>
- #include <workbench/startup.h>
- #include <libraries/dosextens.h>
- #include <functions.h>
- #include <Paul.h>
-
-
- /* I think we're pure, basically... the one variable that gets different
- values on different runs is _savsp, which gets set by crt0. But that's
- cool, because it's never referred to. Tests find no problems. */
-
-
- struct theResidents {
- BPTR next;
- long usecount;
- BPTR seglist;
- ubyte namelength;
- char name[1];
- };
-
-
-
- bool CBsame(c, r) str c; struct theResidents *r;
- {
- str bb = &r->name[0];
- ushort l = r->namelength;
- for ( ; l && *c; l--, c++, bb++)
- if (toupper(*c) != toupper(*bb)) return (false);
- return (!l && !*c);
- }
-
-
-
- BPTR FindResident(s) str s;
- {
- extern struct DosLibrary *DOSBase;
- struct DosInfo *dd;
- struct theResidents *rr;
- dd = gbip(((struct RootNode *) DOSBase->dl_Root)->rn_Info);
- for (rr = gbip((BPTR) dd->di_NetHand); rr; rr = gbip(rr->next))
- if (CBsame(s, rr))
- return (rr->seglist);
- return (null);
- }
-
-
-
- str Chew(alen, aptr) long alen; str aptr;
- {
- while (alen && aptr[alen - 1] <= ' ') aptr[--alen] = 0;
- if (*aptr == '"') {
- if (aptr[alen - 1] == '"') aptr[--alen] = 0;
- aptr++;
- }
- if (aptr[alen]) aptr[--alen] == 0; /* desperation meets crudity */
- if (alen && !(alen == 1 && *aptr == '?'))
- return (aptr);
- else return (null);
- }
-
-
-
- struct WBStartup wbminit = { { {null, null, NT_MESSAGE, 1, null}, null, 40},
- null, null, 1L, null, null};
-
-
- long _main(alen, aptr) long alen; str aptr;
- {
- BPTR mo = FindResident("More");
- APTR con;
- bool loadsegged = false;
- struct Process *me = (adr) FindTask(null);
- struct MsgPort *port, *myport = &me->pr_MsgPort;
- struct WBStartup wbm;
- struct WBArg args[2];
-
- if (!mo) {
- if (mo = LoadSeg("SYS:Utilities/More"))
- loadsegged = true;
- else if (mo = LoadSeg("C:More"))
- loadsegged = true;
- else {
- Write(Output(),
- "Can't find More in resident list, SYS:Utilities, or C:.\n", 56L);
- return (10);
- }
- }
- port = (adr) CreateProc("More used by V", 0L, mo, 4000L);
- wbm = wbminit;
- args[0].wa_Lock = args[1].wa_Lock = me->pr_CurrentDir;
- args[0].wa_Name = "More";
- if (args[1].wa_Name = Chew(alen, aptr)) wbm.sm_NumArgs = 2;
- wbm.sm_Process = port;
- wbm.sm_Message.mn_ReplyPort = myport;
- wbm.sm_Segment = mo;
- wbm.sm_ArgList = &args[0];
- /* what the fuck is ToolWindow for? */
- PutMsg(port, &wbm);
- WaitPort(myport);
- GetMsg(myport); /* flush reply */
- if (loadsegged) UnLoadSeg(mo);
- return (0);
- }
-